import React from "react";
import "./NewsItem.less";
import PropTypes from "prop-types";
import { Link } from "react-router-dom";

const NewsItem = function NewsItem(props) {
  const { info } = props;
  if (!info) return null;
  let { id, title, hint, images } = info;
  if (!Array.isArray(images)) {
    images = [""];
  }
  return (
    <Link to={{ pathname: `/detail/${id}` }}>
      <div className="news-item-box" key={id}>
        <div className="newItemLeft">
          <p className="title">{title}</p>
          <p className="hint">{hint}</p>
        </div>
        <div className="newItemRight">
          <img src={images[0]} alt="" />
        </div>
      </div>
    </Link>
  );
};
// 属性规则处理
// NewsItem.defaultProps={
//     info:null
// }
// NewsItem.PropTypes={
//     info:PropTypes.object
// }
export default NewsItem;
